#ifndef __System_ArrayXSZArrayEnumerator_H__
#define __System_ArrayXSZArrayEnumerator_H__

///<summary>
/// SZArrayEnumerator<T>
///</summary>
//+ requires: Collections_IEnumerator(T)
#define System_ArrayXSZArrayEnumerator(T) bindT(System_ArrayXSZArrayEnumerator,T)
#define Declare_System_ArrayXSZArrayEnumerator(T, Ti) \
	private classT(System_ArrayXSZArrayEnumerator,T,System_Object,classInterface2(Collections_IEnumerator(T),System_ICloneable), \
		private Ti *_array; \
		private int_ _endIndex; \
		private int_ _index; \
	); \
	Declare_CtorT(,internal,System_ArrayXSZArrayEnumerator,T, Array array)
#define Implement_System_ArrayXSZArrayEnumerator(T, Ti) \
	/*[ Clone ] */ \
	public object spaceT(System_ArrayXSZArrayEnumerator,T,Clone)(System_ArrayXSZArrayEnumerator(T) *t) \
	{ \
		return null; \
	} \
	\
	/*[ MoveNext ] */ \
	public bool spaceT(System_ArrayXSZArrayEnumerator,T,MoveNext)(System_ArrayXSZArrayEnumerator(T) *t) \
	{ \
		printf("1a: %d, b: %d\n", t->_index, t->_endIndex); \
		if (t->_index < t->_endIndex) \
		{ \
			t->_index++; \
			return (t->_index < t->_endIndex); \
		} \
		return false; \
	} \
	\
	/*[ Reset ] */ \
	public void spaceT(System_ArrayXSZArrayEnumerator,T,Reset)(System_ArrayXSZArrayEnumerator(T) *t) \
	{ \
		t->_index = -1; \
	} \
	\
	/*[ Current ] */ \
	public Ti spaceT(System_ArrayXSZArrayEnumerator,T,getCurrent)(System_ArrayXSZArrayEnumerator(T) *t) \
	{ \
		if (t->_index < 0) \
		{ \
			throw(InvalidOperationException, L"InvalidOperation_EnumNotStarted"); \
		} \
		if (t->_index >= t->_endIndex) \
		{ \
			throw(InvalidOperationException, L"InvalidOperation_EnumEnded"); \
		} \
		return t->_array[t->_index]; \
	} \
	\
	Implement_TypeT(System_ArrayXSZArrayEnumerator,T,System_Object,typeInterface2(Collections_IEnumerator(T),System_ICloneable), \
		System_ObjectVector *vtable = t->Collections_IEnumerator(T).__vtable; \
		vtable[_Collections_IEnumerator_##T##VIndex_MoveNext] = (System_ObjectVector)&spaceT(System_ArrayXSZArrayEnumerator,T,MoveNext); \
		vtable[_Collections_IEnumerator_##T##VIndex_Reset] = (System_ObjectVector)&spaceT(System_ArrayXSZArrayEnumerator,T,Reset); \
		vtable[_Collections_IEnumerator_##T##VIndex_getCurrent] = (System_ObjectVector)&spaceT(System_ArrayXSZArrayEnumerator,T,getCurrent); \
	) \
	Implement_CtorT(,System_ArrayXSZArrayEnumerator,T, \
		baseCtor(,t,System_Object); \
		t->_array = (Ti *)array; \
		t->_index = -1; \
		t->_endIndex = array_getLength(array); \
		printf("0a: %d, b: %d\n", t->_index, t->_endIndex); \
	, Array array)

#endif /* __System_ArrayXSZArrayEnumerator_H__ */
